package com.dingwen.stumybplu.entity;

import com.baomidou.mybatisplus.annotation.*;

import java.time.LocalDateTime;

import java.io.Serializable;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
import lombok.experimental.Accessors;

/**
 * <p>
 * 系统用户表
 * </p>
 * EqualsAndHashCode(callSuper = false):
 * 默认为false，及忽略父类的属性。当两个子类属性一致时equal比较为true
 * 当为true时表示将父类的属性也纳入比较
 *
 * Accessors(chain = true): get set 方法的生成策略
 * china true: set 方法返回当前对象
 *
 * TableField(value = "create_time", fill = FieldFill.INSERT)
 * fill = FieldFill.INSERT； 插入时自动填充时间
 *
 * TableField(exist = false): 排除非表格字段
 *
 * condition = "%s > #{%s}： 进行非空等值匹配时条件为大于
 *
 * tableField(value = "deleted",select = false)； 查询不显示当前字段
 *
 * TableLogic(value = "0",delval = "1"): 逻辑删除配置
 *
 * Version: 乐观锁实现配置
 *
 * @author dingwen
 * @since 2021-06-07
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("sys_user")
@ApiModel(value = "User对象", description = "系统用户表")
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class User implements Serializable {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "用户ID，主键")
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    @ApiModelProperty(value = "用户名")
    @TableField(value = "name",condition = SqlCondition.LIKE)
    private String name;

    @ApiModelProperty(value = "年龄")
    @TableField(value = "age",condition = "%s > #{%s}")
    private Integer age;

    @ApiModelProperty(value = "邮箱")
    @TableField("email")
    private String email;

    @ApiModelProperty(value = "该用户直属上级用户ID")
    @TableField("manager_id")
    private Long managerId;

    @ApiModelProperty(value = "创建时间")
    @TableField(value = "create_time", fill = FieldFill.INSERT)
    private LocalDateTime createTime;

    @ApiModelProperty(value = "逻辑删除标识,0-未删除,1-已删除")
    @TableField(value = "deleted",select = false)
    @TableLogic(value = "0",delval = "1")
    private Integer deleted;

    @ApiModelProperty(value = "版本")
    @Version
    private Integer version;
}
